/*
*
*学员培训模块接口
*
*/
angular.module('StuRequestTrain', ['Common', 'loadModule', 'ui.router', 'oc.lazyLoad'])
.service('StuRequestTrain', ['Conne_knowl', '$http', "$rootScope", function (Restangular, $http, $rootScope) {


    //拍照
    this.saveface = function (params) {
        return Restangular.one("face").customPOST({ name: "My Message" }, "saveface", params);
    };
    //任务报名
    this.addEnrollInfo = function (params) {
        return Restangular.one("enroll").customPOST({ name: "My Message" }, "addEnrollInfo", params);
    };

    //上传相册
    this.uploadCover = function (params) {
        return $rootScope.fileurl + "/file/uploadCover" + params;
    }
    
    /*************************************************************************************************/
    //生成专栏的问题列表静态页
    this.qaTemplate = function (params) {
        return Restangular.one("forum").customPOST({ name: "My Message" }, "qaTemplate", params);
    };
    //生成问题详情的静态页
    this.template = function (params) {
        return Restangular.one("forum").customPOST({ name: "My Message" }, "template", params);
    };

    //查询问卷
    this.findNegativePersonByOrgId = function (params) {
        return Restangular.one("questionnaire").customPOST({ name: "My Message" }, "findNegativePersonByOrgId", params);
    };
    //更具token获取用户信息
    this.getUserbyToken = function (params) {
        return Restangular.one("user").customPOST({ name: "My Message" }, "getUserbyToken", params);
    };
    //查询开关
    this.getOrgSwitch = function (params) {
        return Restangular.one("switch").customPOST({ name: "My Message" }, "getOrgSwitch", params);
    };


    //获取我的提问
    this.findProblemPage = function (params) {
        return Restangular.one("/interlocution").customPOST({ name: "My Message" }, "findProblemPage", params);
    }
    //获取我的回复
    this.findReplayPage = function (params) {
        return Restangular.one("/interlocution").customPOST({ name: "My Message" }, "findReplayPage", params);
    }
    //上传附件
    this.uploadEnclosure = function (params) {
        return $rootScope.fileurl + "/file/uploadEnclosure" + params;
    }


    //最新10问题排行
    this.findNewPass = function (params) {
        return Restangular.one("/interlocution").customPOST({ name: "My Message" }, "findNewPass", params);
    }
    /**************************************************************************************************************/
    //直播列表
    this.findSectionList = function (params) {
        return Restangular.one("/stage").customPOST({ name: "My Message" }, "findSectionList", params);
    }
    //跳转直播
    this.getTiket = function (params) {
        return Restangular.one("/live").customPOST({ name: "My Message" }, "getTiket", params);
    }
    //查询公告
    this.findStudentNotice = function (params) {
        return Restangular.one("/Operate").customPOST({ name: "My Message" }, "findStudentNotice", params);
    }

    // 从新计算进度
    this.modifyTime = function (params) {
        return Restangular.one("/coursetime").customPOST({ name: "My Message" }, "modifyTime", params);
    }
    // 人员编辑-- 日志获取
    this.personnelLogGetList = function (params) {
        return Restangular.one("/PersonnelManagement").customPOST({ name: "My Message" }, "PersonnelLogGetList", params);
    }
    //用户登录
    this.login = function (params) {
        return Restangular.one("ApiUser").customPOST({ name: "My Message" }, "login", params);
    }
    // 人员编辑获取
    this.personnelGetKey = function (params) {
        return Restangular.one("/PersonnelManagement").customPOST({ name: "My Message" }, "PersonnelGetKey", params);
    }
    // 人员基本信息
    this.token = function (params) {
        return Restangular.one("/ApiUser").customPOST({ name: "My Message" }, "token", params);
    }
    /*
    *   查询知识架构列表
    *   request
    *   userId false string 搜索负责人id
    *  orgId false string 登录人企业id
    *  powerLV false string 权限id
    *  startDate false string 开始时间
    *  endDate false string 结束时间
    *  searchName false string 搜索内容、（知识结构名称或拼音）
    *  knowledge_Id false string 查询子节点参数
    *   respose
    *   errorCode true string 0成功，1失败
    *   datas true array[object]  知识结构集合
    *    
    */
    this.findKnowledgeList = function (params) {
        return Restangular.one("knowledge").customPOST({ name: "My Message" }, "findKnowledgeList", params);
    }
    /**
    获取题目数
    */
    this.getQuestionCount = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "findCountBydifficult", params);
    }
    /**
    提交进度
    */
    this.Uploadprogress = function (params) {
        return Restangular.one("coursedetailed").customPOST({ name: "My Message" }, "Uploadprogress", params);
    }
    /**
    获取用户随机题目
    */
    this.randomQuestions = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "randomQuestions", params);
    }
    /**
    获取用户的答题情况
    */
    this.findGroupNumber = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "findGroupNumber", params);
    }

    /**
    错题知识架构
    */
    this.findKnowledgeQuestion = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "findKnowledgeQuestion", params);
    }
    /**
    查询收藏题库
    */
    this.findCollectionList = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "findCollectionList", params);
    }
    /**
    收藏知识架构
    */
    this.findCollections = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "findCollections", params);
    }
    /**
    查询错题
    */
    this.findReviewError = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "findReviewError", params);
    }
    /**
    错题知识架构
    */
    this.findKnowledgeQuestion = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "findKnowledgeQuestion", params);
    }
    /**
    查询收藏题库
    */
    this.findCollectionList = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "findCollectionList", params);
    }
    /**
    收藏题目
    */
    this.collectionQuestion = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "collectionQuestion", params);
    }
    /**
    取消收藏题目
    */
    this.deleteCollection = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "deleteCollection", params);
    }
    /**
    提交题目信息题目内容    
    questionJSON    题目json
    groupRecord     答题组
    answerCostTime  答题组时长
    userid          用户id
    orgid           企业id
    knowledgeId     知识结构id
    knowledgeName   知识结构名称
    answerXid       知识结构id/题库id、任务、课程、试卷
    */
    this.saveQuestion = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "saveQuestion", params);
    }
    /**
    根据知识分类获取用户的所有试题
    */
    this.findQuestionsPage = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "findQuestionsPage", params);
    }
    /**
    获取人员题库中知识结构中的答题情况
    // 知识结构id
    knowledgeId: '', 
    // 用户id
    userId: '',
    // 组织机构id
    organizationId: '',
    // 入口 （1,任务 2,课程 3,试卷 4,题库）
    opType: '',
    // 任务id、课程id、试卷id、题库id
    searchId:''
    */
    this.getQuesTotleInfo = function (params) {
        return Restangular.one("answerRecord").customPOST({ name: "My Message" }, "getQuesTotleInfo", params);
    }
    /**
    课程收藏
    collectionsId
    courseName
    userId
    courseId
    */
    this.modifyCollectionCourse = function (params) {
        return Restangular.one("course").customPOST({ name: "My Message" }, "modifyCollectionCourse", params);
    }
    /**
    获取公开课
    orgid
    knowledgeids
    searchText
    searchType
    cstype
    pageIndex
    pageSize
    */
    this.findOpen = function (params) {
        return Restangular.one("course").customPOST({ name: "My Message" }, "findOpen", params);
    }
    /**
    记录文件预览次数
    */
    this.PreviewNumber = function (params) {
        return Restangular.one("Kapi").customPOST({ name: "My Message" }, "PreviewNumber", params);
    }
    /**
    获取首页前六共享文件
    */
    this.getTopSixShareList = function (params) {
        return Restangular.one("Kapi").customPOST({ name: "My Message" }, "getTopSixShareList", params);
    }
    /**
    获取个人统计信息
    userid 用户id
    orgid 企业id
    org_Id 学员的部门        
    role_Id 学员的角色
    user_groupId 学员的用户组
    */
    this.stuTotleInfo = function (params) {
        return Restangular.one("exampaper").customPOST({ name: "My Message" }, "stuTotleInfo", params);
    }
    /**
    查询最近学习的前三个课程
    userid
    */
    this.studyCourseTopThree = function (params) {
        return Restangular.one("exampaper").customPOST({ name: "My Message" }, "studyCourseTopThree", params);
    }
    /**
    *查询学员进度
    * request
    *       orgID false string 登录人的企业id
    *       name false string 任务名称
    *       user_id false string 15d5,dg523，fdgf4d23 用户ID、
    *       org_Id false string fds,45g3d,f 企业id
    *       role_Id false string g54,5fds,pju24 角色id
    *       user_groupId false string f1d51g，4fd53s,4fdsa 用户组id
    *       pageSize false string
    *       pageIndex false string
    *response
    * 
    *       培训任务对象
    *    
    */


    this.findStudentStage = function (params) {
        //        return $http({
        //            url: "/api/trainingtasklist.json",
        //            method: 'GET'
        //        });
        return Restangular.one("stage").customPOST({ name: "My Message" }, "findStudentStage", params);
    }


    /*
    *查询学员的任务阶段内容
    * request
    *   courseids true string 课程id，以，做分隔
    *   paperids true string 试卷id,以，做分隔
    *   upids true string 文件id,以，做分隔
    *   knowledgeids true string 知识结构id,以，做分隔
    *   pageIndex true string 当前页码
    *   pageSize true string 当前显示条数
    * response
    *       errorcode
    *       datas
    */
    this.findArrangeStage = function (params) {
        //        return $http({
        //            url: "/api/stutrainingtaskcourelist.json",
        //            method: 'GET'
        //        });
        return Restangular.one("stage").customPOST({ name: "My Message" }, "findArrangeStage", params);
    }

    //占住
    /************************************************************************/
    //查询企业的客服列表
    //params:orgId  企业id
    this.findCustomer = function (params) {
        return Restangular.one("/customer").customPOST({ name: "My Message" }, "findCustomer", params);
    }
    //查询当前企业的信息
    //orgId  当前登录人的企业id
    this.findOrgInfo = function (params) {
        return Restangular.one("/organizationInfo").customPOST({ name: "My Message" }, "findOrgInfo", params);
    }
    //查询当前任务的已完成的课程、试卷id
    this.findOneProgress = function (params) {
        return Restangular.one("/stage").customPOST({ name: "My Message" }, "findOneProgress", params);

    }
    /**
    查询课程收藏
    userid 用户id
    orgid 企业id
    pageIndex 当前页
    pageSize 当前页面的数量
    */
    this.courseCollection = function (params) {
        return Restangular.one("/exampaper").customPOST({ name: "My Message" }, "courseCollection", params);
    }
    /**
    查询考试历史记录
    pageIndex 当前页
    pageSize 当前条数
    userid 用户id
    */
    this.historyPaper = function (params) {
        return Restangular.one("/exampaper").customPOST({ name: "My Message" }, "historyPaper", params);
    }
    /**
    保存用户基本信息
    */
    this.updateStuInfo = function (params) {
        return Restangular.one("/exampaper").customPOST({ name: "My Message" }, "updateStuInfo", params);
    }
    /***
    获取最近七天的提醒
    */
    this.getSevenArrange = function (params) {
        return Restangular.one("/exampaper").customPOST({ name: "My Message" }, "getSevenArrange", params);
    }
    /**
    获取班级列表
    */
    this.getClassList = function (params) {
        return Restangular.one("/order").customPOST({ name: "My Message" }, "findStudentGradePage", params);
    }
    /**
    更具班级id获取班级子表数据
    */
    this.getClassDetailList = function (params) {
        return Restangular.one("/grade").customPOST({ name: "My Message" }, "findGradeDetails", params);
    }
    /**
     *  获取已考次数
     */
    this.getExamNum = function(params){
        return Restangular.one("/score").customPOST({name:"My Message"},"getExamNum",params);
    }
} ])


